{% block sw_order_detail_general %}
<div class="sw-order-detail-general">
    {% block sw_order_detail_general_info_card %}
    <mt-card
        class="sw-order-detail-base__general-info"
        position-identifier="sw-order-detail-general-info"
        :title="$tc('sw-order.detailBase.cardTitleGeneralInfo')"
    >
        {% block sw_order_detail_general_info %}
        <sw-order-general-info
            ref="swOrderGeneralInfo"
            :order="order"
            @save-edits="onSaveEdits"
        />
        {% endblock %}
    </mt-card>
    {% endblock %}

    {% block sw_order_detail_general_line_items_card %}
    <sw-extension-component-section
        position-identifier="sw-order-detail-base-line-items__before"
    />

    <mt-card
        class="sw-order-detail-general__line-item-grid-card"
        position-identifier="sw-order-detail-general-line-items"
        :is-loading="loading.recalculation"
        :title="$tc('sw-order.detailBase.cardTitleLineItems')"
    >

        {% block sw_order_detail_general_line_items_card_rows %}
        <template #grid>
            <sw-container type="row">
                {% block sw_order_detail_general_line_items_grid %}
                <sw-order-line-items-grid
                    ref="sw-order-line-item-grid"
                    :order="order"
                    :context="versionContext"
                    :editable="acl.can('order.editor')"
                    @item-delete="recalculateAndReload"
                    @item-edit="recalculateAndReload"
                    @existing-item-edit="saveAndRecalculate"
                    @item-cancel="recalculateAndReload"
                />
                {% endblock %}

                {% block sw_order_detail_general_line_items_summary %}
                <sw-card-section
                    divider="top"
                    slim
                >
                    <sw-description-list
                        class="sw-order-detail__summary"
                        grid="1fr 1fr"
                    >

                        {% block sw_order_detail_general_line_items_summary_entries %}
                        {% block sw_order_detail_general_line_items_summary_amount %}
                        <dt>{{ $tc('sw-order.detailBase.summaryLabelAmount') }}</dt>
                        <dd>{{ currencyFilter(order.positionPrice, currency.isoCode, order.totalRounding.decimals) }}</dd>
                        {% endblock %}

                        {% block sw_order_detail_general_line_items_summary_shipping_cost %}
                        <template v-if="delivery">
                            <!-- eslint-disable-next-line vuejs-accessibility/click-events-have-key-events, vuejs-accessibility/no-static-element-interactions -->
                            <dt
                                @click="$refs.editShippingCosts.onClick()"
                            >
                                {{ $tc('sw-order.detailBase.summaryLabelShippingCosts') }}
                            </dt>
                            <dd>
                                <sw-order-saveable-field
                                    ref="editShippingCosts"
                                    v-tooltip="{
                                        showDelay: 300,
                                        message: shippingCostsDetail,
                                        disabled: taxStatus === 'tax-free'
                                    }"
                                    type="number"
                                    :editable="acl.can('order.editor')"
                                    :step="1"
                                    :min="0"
                                    :value="delivery.shippingCosts.totalPrice"
                                    @value-change="onShippingChargeEdited"
                                    @update:value="onShippingChargeUpdated"
                                >
                                    {{ currencyFilter(delivery.shippingCosts.totalPrice, currency.isoCode, order.totalRounding.decimals) }}
                                </sw-order-saveable-field>
                            </dd>
                        </template>

                        <template
                            v-for="(delivery, index) in deliveryDiscounts"
                            :key="index"
                        >
                            <dt>
                                {{ $tc('sw-order.detailBase.discountLabelShippingCosts') }}
                            </dt>
                            <dd>
                                {{ currencyFilter(delivery.shippingCosts.totalPrice, currency.isoCode, order.totalRounding.decimals) }}
                            </dd>
                        </template>
                        {% endblock %}

                        {% block sw_order_detail_general_line_items_summary_amount_without_tax %}
                        <template v-if="taxStatus !== 'tax-free'">
                            <dt><strong>{{ $tc('sw-order.detailBase.summaryLabelAmountWithoutTaxes') }}</strong></dt>
                            <dd><strong>{{ currencyFilter(order.amountNet, currency.isoCode, order.totalRounding.decimals) }}</strong></dd>
                        </template>
                        {% endblock %}

                        {% block sw_order_detail_general_line_items_summary_taxes %}
                        <template v-if="taxStatus !== 'tax-free'">
                            <template
                                v-for="(calculatedTax, index) in sortedCalculatedTaxes"
                                :key="index"
                            >
                                <dt>
                                    {{ $tc('sw-order.detailBase.summaryLabelTaxes', { taxRate: calculatedTax.taxRate }, 1) }}
                                </dt>
                                <dd>
                                    {{ currencyFilter(calculatedTax.tax, currency.isoCode, order.totalRounding.decimals) }}
                                </dd>
                            </template>
                        </template>
                        {% endblock %}

                        {% block sw_order_detail_general_line_items_summary_amount_total %}
                        <template v-if="taxStatus !== 'tax-free'">
                            <dt><strong>{{ $tc('sw-order.detailBase.summaryLabelAmountTotal') }}</strong></dt>
                            <dd><strong>{{ currencyFilter(orderTotal, currency.isoCode, order.totalRounding.decimals) }}</strong></dd>
                            <template v-if="displayRounded">
                                <dt><strong>{{ $tc('sw-order.detailBase.summaryLabelAmountTotalRounded') }}</strong></dt>
                                <dd><strong>{{ currencyFilter(order.price.totalPrice, currency.isoCode, order.totalRounding.decimals) }}</strong></dd>
                            </template>
                        </template>
                        {% endblock %}

                        {% block sw_order_detail_general_line_items_summary_amount_free_tax %}
                        <template v-if="taxStatus === 'tax-free'">
                            <dt><strong>{{ $tc('sw-order.detailBase.summaryLabelAmount') }}</strong></dt>
                            <dd><strong>{{ currencyFilter(order.price.totalPrice, currency.isoCode, order.totalRounding.decimals) }}</strong></dd>
                        </template>
                        {% endblock %}
                    {% endblock %}
                    </sw-description-list>
                </sw-card-section>
                {% endblock %}
            </sw-container>
        </template>
        {% endblock %}
    </mt-card>

    <sw-extension-component-section
        position-identifier="sw-order-detail-base-line-items__after"
    />

    <mt-card
        class="sw-order-detail-general__promotions-card"
        position-identifier="sw-order-detail-general-promotions"
        :title="$tc('sw-order.detailBase.cardTitlePromotions')"
    >
        {# @deprecated tag:v6.8.0 - remove `@loading-change` #}
        <sw-order-promotion-field
            class="sw-order-detail-general__promotions"
            @loading-change="updateLoading"
            @reload-entity-data="reloadEntityData"
            @save-and-reload="saveAndReload"
            @error="showError"
        />
    </mt-card>

    <sw-extension-component-section
        position-identifier="sw-order-detail-base-promotions__after"
    />
    {% endblock %}
</div>
{% endblock %}
